/*
# Vulnerability.h
#
# Copyright (c) 2012 Attique Dawood, Awais Aslam
#
# This file is part of Vulnerability program provided with Automated Worm Fingerprinting.
#
# This software is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software.  If not, see <http://www.gnu.org/licenses/>.
#
#################################################################################
*/
#include <bitset>
using std::bitset;

#define MODE_INFECTED_NONE_FLAG	0x00
#define MODE_INFECTED_V01_FLAG	0x01
#define MODE_INFECTED_V02_FLAG	0x02
#define MODE_INFECTED_ALL_FLAG	0xFF

#define WORM_V01_INFECTION		"W_01_IN_8BAD"
#define WORM_V02_INFECTION		"W_02_IN_103E_A23409BD30924E90423FFAC"	// 36 bytes signature.

enum MODE_OF_OPERATION
{
	MODE_NORMAL = 0,
	MODE_INFECTED_V01 = 1,
	MODE_INFECTED_V02 = 2,
	MODE_INFECTED_ALL = 3
};

class CVulnerability
{
	MODE_OF_OPERATION Mode;
public:
	bitset<8> InfectionFlags;

	CVulnerability();
	void Initialize(MODE_OF_OPERATION = MODE_NORMAL);
	void Run();

	void SetMode(MODE_OF_OPERATION pMode) { Mode = pMode; }
	MODE_OF_OPERATION GetMode() { return Mode; }

};

// Creates a string with given length and random values.
char* RandomString (int=15, int=65, int=25);

// RC4 Encrypt.
char* RC4_Encrypt(unsigned char *, char *, int);

// Safe calls.
void SafeCall (int, const char *, int=-1);
void SafeCallAssert (int, const char *, int=0);

// Compare two blocks of memory and returns true if they match else returns false.
bool memncmp (const char *, const char *, int);
// Memcopy.
void memncpy (char *, const char *, int);